"""add team_providers_tables

Revision ID: 63ca6eebc24c
Revises: f7661070ec23
Create Date: 2025-11-24 11:35:14.455588

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "63ca6eebc24c"
down_revision: Union[str, Sequence[str], None] = "f7661070ec23"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "team_providers",
        sa.Column("id", sa.String(), nullable=False),
        sa.Column("team_id", sa.String(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("type", sa.String(), nullable=False),
        sa.Column("config", sa.JSON(), nullable=False),
        sa.Column("created_by_user_id", sa.String(), nullable=False),
        sa.Column("created_at", sa.DateTime(), server_default=sa.text("(CURRENT_TIMESTAMP)"), nullable=False),
        sa.Column("updated_at", sa.DateTime(), server_default=sa.text("(CURRENT_TIMESTAMP)"), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index("idx_team_provider_name", "team_providers", ["team_id", "name"], unique=False)
    op.create_index(op.f("ix_team_providers_team_id"), "team_providers", ["team_id"], unique=False)
    op.create_index(op.f("ix_team_providers_type"), "team_providers", ["type"], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_team_providers_type"), table_name="team_providers")
    op.drop_index(op.f("ix_team_providers_team_id"), table_name="team_providers")
    op.drop_index("idx_team_provider_name", table_name="team_providers")
    op.drop_table("team_providers")
    # ### end Alembic commands ###
